<admintpl file="header" />
<style type="text/css">
.pic-list li {
	margin-bottom: 5px;
}
</style>
<script type="text/html" id="photos-item-wrapper">
	<li id="savedimage{id}">
		<input id="photo-{id}" type="hidden" name="photos_url[]" value="{filepath}"> 
		<input id="photo-{id}-name" type="text" name="photos_alt[]" value="{name}" style="width: 160px;" title="图片名称">
		<img id="photo-{id}-preview" src="{url}" style="height:36px;width: 36px;" onclick="parent.image_preview_dialog(this.src);">
		<a href="javascript:upload_one_image('图片上传','#photo-{id}');">替换</a>
		<a href="javascript:(function(){$('#savedimage{id}').remove();})();">移除</a>
	</li>
</script>
</head>
<body>
	<div class="wrap js-check-wrap">
		<ul class="nav nav-tabs">
			<li><a href="{:U('ad/index')}">广告管理</a></li>
			<li class="active"><a href="{:U('ad/add')}">广告添加</a></li>
		</ul>
		<form action="{:U('ad/add_post')}" id="adadd" method="post" class="form-horizontal js-ajax-form" enctype="multipart/form-data">
			<div class="row-fluid">
				<div class="span9">
					<table class="table table-bordered">
						<tr>
							<th width="80">广告类型</th>
							<td>
								<select style="max-height: 100px;" name="frm[classid]" onchange="changeadcon(this.value)">
									<option value="1">轮播图</option>
									<option value="2">图片</option>
									<option value="3">文字</option>
								</select>
							</td>
						</tr>
						<tr>
						<th width="80">广告名称</th>
							<td>
								<input type="text" style="width:400px;" name="frm[ad_name]" id="ad_name" value="" placeholder="广告名称"/>
								<span class="form-required">*</span>
							</td>
						</tr>
						<th width="80">广告标识</th>
							<td>
								<input type="text" style="width:400px;" name="frm[ad_ident]" id="ad_ident" value="" placeholder="广告标识"/>
								<span class="form-required">*用于前台调用</span>
							</td>
						</tr>
						<tr id="showwordad">
							<th>文字广告</th>
							<td>
								<input type="text" style="width:400px;" name="frm[ad_content]" id="ad_content"  value="" placeholder="请填写文字广告内容" />
							</td>
						</tr>
						<tr id="url">
							<th>外链地址</th>
							<td>
								<input type="text" style="width:400px;" name="frm[linkurl]" id="linkurl"  value="" placeholder="请填写跳转地址" />
							</td>
						</tr>
						<tr id="picad">
							<th>广告图片</th>
							<td>
								<input type="hidden" name="frm[thumb]" id="thumb" value="">
								<a href="javascript:upload_one_image('图片上传','#thumb');" class="btn btn-small">广告图片上传</a>
								<input type="button" class="btn btn-small" onclick="$('#thumb-preview').attr('src','__TMPL__Public/assets/images/default-thumbnail.png');$('#thumb').val('');return false;" value="取消图片">
							</td>
						</tr>
						<tr id="showpicad">
							<th>图片展示</th>
							<td style="text-align: center;">
								<img src="__TMPL__Public/assets/images/default-thumbnail.png" id="thumb-preview" style="cursor: hand;max-width:870px;width:auto;height:300px;" />
							</td>
						</tr>
					</table>
				</div>
				<div class="span3">
					<table class="table table-bordered">
						<tr>
							<th><b>发布时间</b></th>
						</tr>
						<tr>
							<td><input type="text" name="frm[create_time]" value="{:date('Y-m-d H:i:s',time())}" class="js-datetime" style="width: 160px;"></td>
						</tr>
						<tr>
							<th><b>状态</b></th>
						</tr>
						<tr>
							<td>
								<label class="radio"><input type="radio" name="frm[status]" value="1" checked>启用</label>
								<label class="radio"><input type="radio" name="frm[status]" value="2">禁用</label>
							</td>
						</tr>
						<tr>
							<th><b>是否添加外链</b></th>
						</tr>
						<tr>
							<td>
								<label class="radio"><input type="radio" name="frm[is_link]" value="1" onclick="getisurl(this.value)">是</label>
								<label class="radio"><input type="radio" name="frm[is_link]" value="0" checked  onclick="getisurl(this.value)">否</label>
							</td>
						</tr>
					</table>
				</div>
			</div>
			<div class="form-actions">
				<button class="btn btn-primary js-ajax-submit" type="submit">提交</button>
				<a class="btn" href="{:U('Ad/index')}">返回</a>
			</div>
		</form>
	</div>
	<script src="__PUBLIC__/js/common.js"></script>
	<script type="text/javascript">
		$(function() {
			changeadcon("1");
			getisurl("0");
		});
		function changeadcon(val){
			if(val == "1"){
				$("#showwordad").css("display","none");
				$("#picad").css("display","");
				$("#showpicad").css("display","");
			}else if(val == "2"){
				$("#showwordad").css("display","none");
				$("#picad").css("display","");
				$("#showpicad").css("display","");
			}else if(val == "3"){
				$("#showwordad").css("display","");
				$("#picad").css("display","none");
				$("#showpicad").css("display","none");
			}
		}
		function getisurl(val){
			if(val == "1"){
				$("#url").css("display","");
			}else{
				$("#url").css("display","none");
			}
		}
	</script>
</body>
</html>